<?php 
class productcode
{
        private $id;
        private $category_level_2_id;
        private $category_level_3_id;
        private $product_fit_id;
        private $product_crotch_id;
        private $code;
        private $description;
		
        public function get_productcode($id)
        {
                $m_query = "select * from product_code where id='{$id}'";
                $m_sql = mysql_query($m_query);
                if(isset($m_sql) && mysql_num_rows($m_sql)>0)
                {
                        $m_result = mysql_fetch_assoc($m_sql);
                        $this->id = $m_result['id'];
                        $this->category_level_2_id = $m_result['category_level_2_id'];
                        $this->category_level_3_id = $m_result['category_level_3_id'];
                        $this->product_fit_id = $m_result['product_fit_id'];
                        $this->product_crotch_id = $m_result['product_crotch_id'];
                        $this->code = $m_result['code'];
                        $this->description = $m_result['description'];
                }
        }
		
        public function get_id()
        {
                return $this->id;
        }

        public function set_id($id)
        {
                $this->id = $id;
        }
		
        public function get_description()
        {
                return $this->description;
        }

        public function set_description($description)
        {
                $this->description = $description;
        }
		
        public function get_code()
        {
                return $this->code;
        }

        public function set_code($code)
        {
                $this->code = $code;
        }
		
        public function get_product_crotch_id()
        {
                return $this->product_crotch_id;
        }

        public function set_product_crotch_id($product_crotch_id)
        {
                $this->product_crotch_id = $product_crotch_id;
        }
		
        public function get_category_level_2_id()
        {
                return $this->category_level_2_id;
        }

        public function set_category_level_2_id($category_level_2_id)
        {
                $this->category_level_2_id = $category_level_2_id;
        }
        
        public function get_category_level_3_id()
        {
                return $this->category_level_3_id;
        }

        public function set_category_level_3_id($category_level_3_id)
        {
                $this->category_level_3_id = $category_level_3_id;
        }
        
        public function get_product_fit_id()
        {
                return $this->product_fit_id;
        }

        public function set_product_fit_id($product_fit_id)
        {
                $this->product_fit_id = $product_fit_id;
        }
        
     
        public function create()
        {
                $m_query = "insert into product_code (category_level_2_id,category_level_3_id,product_fit_id,product_crotch_id,code,description)
                                        values ('{$this->category_level_2_id}','{$this->category_level_3_id}','{$this->product_fit_id}','{$this->product_crotch_id}','{$this->code}','{$this->description}')";
                $m_sql = mysql_query($m_query);
                if($m_sql)
                        return true;
                else return false;
        }
        
        public function update()
        {
                $m_query = "update product_code 
                                        set category_level_2_id='{$this->category_level_2_id}',
											category_level_3_id='{$this->category_level_3_id}',
											product_fit_id='{$this->product_fit_id}',
											product_crotch_id='{$this->product_crotch_id}',
											code='{$this->code}',
                                            description='{$this->description}' 
                                        where id={$this->id}";
                $m_sql = mysql_query($m_query);
                if($m_sql)
                        return true;
                else return false;
        }
		
        public function del()
        {
                $m_query = "delete from product_code where id={$this->id}";
                $m_sql = mysql_query($m_query);
                if($m_sql)
                        return true;
                else return false;
        }
}

?>